package com.jiangruan.javaproject.service;

import com.jiangruan.javaproject.Constants;
import com.jiangruan.javaproject.request.HttpUtils;

import java.net.URLEncoder;
import java.util.Scanner;

/**
 * @author:xulonghua
 * @email:3162193565@qq.com
 * @desc:聚合函数API天气功能
 * @datetime 2021/12/26 15:55
 */
public class Weather {
    public  String weather(){
        Scanner scanner = new Scanner ( System.in );
        System.out.println ("输入你要查询的城市");
        String city = scanner.next ();
        String citys = URLEncoder.encode ( city );
        String url= Constants.WEATHER_URL+"?city="+citys+"&key="+Constants.Weather_KEY;
        String result = HttpUtils.get ( url );
        return result;
    }

    public static void main(String[] args) {

    }
}
